﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Net;
using Newtonsoft.Json;
using System.Net.Http;
using System.Net.Http.Headers;
using Water.Model;
using WaterApp.Common;

namespace WaterApp.QueryReport
{
    public partial class PipeNetCheckPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindPipeNetChecks();
            }
        }

        private void BindPipeNetChecks()
        {
            string url = WebapiUrl.weburl() + "GetPipeNetChecks";
            PipeNetCheckCon pncc = new PipeNetCheckCon()
            {
                 checkdt = tbguzhrq.Text,
                 checkadd = tbaddress.Text,
                 checkman = tbcheckemp.Text
            };
            var requestJson = JsonConvert.SerializeObject(pncc);
            HttpContent httpContent = new StringContent(requestJson);
            httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var httpClient = new HttpClient();
            var responseJson = httpClient.PostAsync(url, httpContent).Result.Content.ReadAsStringAsync().Result;
            IList<PipeNetCheckQuery> mr = JsonConvert.DeserializeObject<IList<PipeNetCheckQuery>>(responseJson);
            if (mr == null)
            {
                lbmessage.Text = "没有找到相关记录！请重新输入查询条件！";
                return;
            }
            Gvpipenetch.DataSource = mr;
            Gvpipenetch.DataBind();
        }

        protected void pipenetchfound_Click(object sender, EventArgs e)
        {
            BindPipeNetChecks();
        }
    }
}